package com.qjc.demo.mybatis;

import com.qjc.demo.mybatis.entity.Role;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @Description:
 * @Author: qjc
 * @Date: 2020/7/30
 */
public class MybatisSourceCodeTest {

    //调试mybatis源码
    public static void main(String[] args) throws IOException {
        InputStream resourceAsStream = Resources.getResourceAsStream("mybatis-config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        for (int i = 0; i < 2; i++) {
            Role role = sqlSession.selectOne("com.qjc.demo.mybatis.dao.RoleMapper.selectByPrimaryKey", 1);
            System.err.println(role.toString());
        }
    }
}
